package org.agent.aigccore.model.bo;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.agent.aigccore.basic.enums.IotDeviceIoStatusEnum;
import org.agent.aigccore.basic.enums.IotDeviceStatusEnum;
import org.agent.aigccore.basic.enums.IotDeviceWorkStatusEnum;
import org.agent.aigccore.basic.enums.RobotScopeEnum;
import org.agent.aigccore.basic.serializable.BaseExtInfoBaseDBModel;
import org.agent.aigccore.basic.serializable.CustomConverter;
import org.agent.aigccore.model.po.IotDevicePO;
import org.agent.aigccore.model.vo.IotDeviceVO;
import org.mapstruct.DecoratedWith;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

/**
 * IoT设备BO类
 */
@Slf4j
@Setter
@Getter
@Schema(description = "IoT设备业务对象")
public class IotDeviceBO extends BaseExtInfoBaseDBModel {

    private String deviceName;
    private IotDeviceStatusEnum deviceStatus;
    private IotDeviceWorkStatusEnum workStatus;
    private IotDeviceIoStatusEnum ioStatus;
    private String devicePosition;
    private RobotScopeEnum robotScope;
    private String businessGroup;
    private String businessTaskNo;
    private String deviceIp;
    private String devicePort;
    private String projectId;

    public static final Convert convert = Mappers.getMapper(Convert.class);

    @Mapper(uses = CustomConverter.class)
    @DecoratedWith(AbstractDecoder.class)
    public interface Convert {
        IotDevicePO toPO(IotDeviceBO iotDeviceBO);

        IotDeviceBO formPO(IotDevicePO iotDevicePO);

        IotDeviceVO toVO(IotDeviceBO bo);

        IotDeviceBO fromVO(IotDeviceVO vo);
    }

    /**
     * 抽象转换器
     */
    public static abstract class AbstractDecoder implements Convert {
        private final Convert convert;

        public AbstractDecoder(Convert convert) {
            this.convert = convert;
        }
    }
}